﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QQMusic.API
{
    public class Arrays
    {
        /// <summary>
        /// 复制集合
        /// </summary>
        public static T Copy<T, E>(T collection, int start, int end) where T : IList<E>, new()
        {
            T t = new T();
            if (start > end)
                throw new Exception("end is more big than start !");
            for (int i = start; i < end; i++)
            {
                if (collection.Count > i)
                    t.Add(collection[i]);
            }
            return t;
        }

        /// <summary>
        /// 复制集合
        /// </summary>
        public static T Copy<T, E>(T collection, int start) where T : IList<E>, new()
        {
            return Copy<T, E>(collection, start, collection.Count);
        }
    }
}
